home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / HyperCard Goodies / HyperCard Dev. ToolKit / XCMD.Sources / breakSPort.p next >
Text File  |  1987-08-17  |  2KB  |  82 lines

  1. {$R-}
  2.  
  3. (*
  4.     breakSPort(port number, trueOrFalse) -- Send or clear a break on the serial port.
  5.     By Harry Chesley.  DO NOT call the author!  Contact Apple Developer 
  6.     Support on AppleLink "MacDTS" or on MCI "MacTech".
  7.  
  8.     ©Apple Computer, Inc. 1987
  9.     All Rights Reserved.
  10.  
  11.     To compile and link this file using Macintosh Programmer's Workshop,
  12.  
  13.     pascal -w breakSPort.p
  14.     link -m ENTRYPOINT -o HyperTerm -rt XCMD=1 -sn Main=breakSPort breakSPort.p.o "{MPW}"Libraries:interface.o
  15.     
  16. *)
  17.  
  18. {$S breakSPort }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. type
  31.  
  32. Str31 = String[31];
  33.  
  34. procedure breakSPort(paramPtr: XCmdPtr); forward;
  35.  
  36. procedure EntryPoint(paramPtr: XCmdPtr);
  37.  
  38.     begin
  39.         breakSPort(paramPtr);
  40.     end;
  41.  
  42. procedure breakSPort(paramPtr: XCmdPtr);
  43.  
  44.     var portNumber: integer;
  45.         setting: integer;
  46.         outPort: integer;
  47.         str: Str255;
  48.         doBreak: boolean;
  49.  
  50.     {$I XCmdGlue.inc}
  51.  
  52.     procedure Fail(errMsg: Str255); { set theResult and quit }
  53.         begin
  54.             paramPtr^.returnValue := PasToZero(errMsg);
  55.             exit(breakSPort);
  56.         end;
  57.  
  58.     begin
  59.         if paramPtr^.paramCount <> 2 then Fail('parameter count is not 2');
  60.  
  61.         ZeroToPas(paramPtr^.params[1]^,str);        { First parameter is port number. }
  62.         portNumber := StrToNum(str);
  63.         if (portNumber < 1) or (portNumber > 2) then Fail('invalid port number');
  64.         ZeroToPas(paramPtr^.params[2]^,str);        { Second parameter is setting. }
  65.         doBreak := false;
  66.         if length(str) > 0 then
  67.             if (str[1] = 't') or (str[1] = 'T') then doBreak := true;
  68.  
  69.         if portNumber = 1 then outPort := -7
  70.         else outPort := -9;
  71.         if doBreak then
  72.             begin
  73.                 if SerSetBrk(outPort) <> noErr then Fail('SerSetBrk failed');
  74.             end
  75.         else
  76.             begin
  77.                 if SerClrBrk(outPort) <> noErr then Fail('SerClrBrk failed');
  78.             end;
  79.     end;
  80.  
  81. end.
  82.